#include <bits/stdc++.h>
using namespace std;

int n, m;

const int N = 3e5+5;

typedef long long LL;

template<typename T>
struct SegT {
    static const int N = (300000+5) << 2;
    int nn;

    T dat[N], lazy[N];

    inline void pu(int rt) {
        dat[rt] = dat[rt<<1] + dat[rt<<1|1];
    }

    inline void pd(int rt) {
        if (lazy[rt]) {
            int ls = rt<<1, rs = rt<<1|1;
            dat[ls] += lazy[rt];
            dat[rs] += lazy[rt];
            lazy[ls] += lazy[rt];
            lazy[rs] += lazy[rt];
            lazy[rt] = 0;
        }
    }

    void init(int n) {
        nn = 1;
        while (nn < n) nn <<= 1;
        memset(dat, 0, sizeof(dat[0]) * (2*nn));
    }

    int L, R;
    void upt(int l, int r, T v, int rt) {
        if (L <= l && r <= R) {
            dat[rt] += v;
            lazy[rt] += v;
            return;
        }
        int m = (l+r) >> 1;
        pd(rt);
        if (L <= m) upt(l, m, v, rt<<1);
        if (m+1<=R) upt(m+1, r, v, rt<<1|1);
        pu(rt);
    }

    T q(int l, int r, int rt) {
        if (L <= l && r <= R) {
            return dat[rt];       
        }
        int m = (l+r) >> 1;
        pd(rt);
        T res = 0;
        if (L <= m) res += q(l, m, rt<<1);
        if (m+1<=R) res += q(m+1,r,rt<<1|1);
        return res;
    }

    inline void u(int l, int r, T v) {
        L = l;
        R = r;
        upt(1, nn, v, 1);
    }

    inline T q(int l, int r) {
        return q(1, nn, 1);
    }
};

int dep[N], id[N], fa[N];
vector<int> G[N];

LL ans[N];

namespace HLD {
    int top[N], d[N], f[N], son[N], rid[N], siz[N];
    int dfn;

    SegT<int> s1, s2;
    int sum1[N];

    void dfs1(int u, int la, int depth) {
        // printf("dfs1 %d %d %d\n", u, la, depth);
        dep[u] = depth;
        fa[u] = la;
        son[u] = -1;
        siz[u] = 1;
        for (int v : G[u]) {
            if (v == la) continue;
            dfs1(v, u, depth + 1);
            siz[u] += siz[v];
            if (!~son[u] || siz[v] > siz[son[u]])
                son[u] = v;
        }
    }

    void dfs2(int u, int la, int t) {
        id[u] = ++dfn;
        rid[id[u]] = u;
        top[id[u]] = id[t];
        d[id[u]] = dep[u];
        f[id[u]] = id[la];
        for (int v : G[u]) {
            if (v == la) continue;
            if (v == son[u]) dfs2(v, u, t);
            else dfs2(v, u, v);
        }
    }

    inline int lca(int u, int v) {
        for (u=id[u], v=id[v];top[u]!=top[v]; u=f[top[u]]) {
            if (d[top[u]] < d[top[v]]) swap(u, v);
        }
        if (d[u] < d[v]) swap(u, v);
        return rid[v];
    }

    void init(int root) {
        dfn = 0;
        dfs1(root, root, 1);
        dfs2(root, root, root);
    }

    void go(int u, int v, int T) {
        for (u=id[u], v=id[v];top[u]!=top[v]; u=f[top[u]]) {
            s1.u(top[u], u, T);
            if (d[top[u]] < d[top[v]]) swap(u, v);
        }
        if (v + 1 <= u) s1.u(v + 1, u, T);
    }

    void dbg(int n) {
        for (int i=1; i<=n; ++i) {
            printf("i=%d, id=%d, rid=%d, top=%d\n", i, id[i], rid[i], top[i]);
        }
    }
    void calc() {
        
    }
}


struct path {
    int u, v, lca;
    path(){}
    path(int u, int v):u(u), v(v) {
        lca = HLD::lca(u, v);
    }

} a[N];

int main(int argc, char const *argv[])
{
    scanf("%d%d", &n, &m);
    for (int i=0; i<n-1; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }

    HLD::init(1);
    // return 0;
    HLD::s1.init(n);

    HLD::dbg(n);

    for (int i=0; i<m; ++i) {
        int x, y;
        scanf("%d%d", &x, &y);
        a[i] = path(x, y);

        int l1 = dep[a[i].u] - dep[a[i].lca],
        l2 = dep[a[i].v] - dep[a[i].lca];

        HLD::go(a[i].lca, a[i].u, -l1);
        HLD::go(a[i].lca, a[i].v, -l2);
        // HLD::go2(a[i].lca, 1LL * l1 * l2);
        ans[a[i].lca] += 1LL * l1 * l2;
        printf("%d %d %d %lld\n", a[i].u, a[i].v, a[i].lca, 1LL * l1 * l2);
    }


    for (int i=1; i<=n; ++i) {
        ans[HLD::rid[i]] += HLD::s1.q(1, i);
    }

    for (int i=1; i<=n; ++i)
        printf("%lld\n", ans[i]);
    

    
    return 0;
}
